
<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Datatables</title>

    <!-- Main Styles -->
    <link rel="stylesheet" href="../../static/styles/style.min.css">

    <!-- Material Design Icon -->
    <link rel="stylesheet" href="../../static/fonts/material-design/css/materialdesignicons.css">

    <!-- mCustomScrollbar -->
    <link rel="stylesheet" href="../../static/plugin/mCustomScrollbar/jquery.mCustomScrollbar.min.css">

    <!-- Waves Effect -->
    <link rel="stylesheet" href="../../static/plugin/waves/waves.min.css">

    <!-- Sweet Alert -->
    <link rel="stylesheet" href="../../static/plugin/sweet-alert/sweetalert.css">

    <!-- Data Tables -->
    <link rel="stylesheet" href="../../static/plugin/datatables/media/css/dataTables.bootstrap.min.css">
    <link rel="stylesheet" href="../../static/plugin/datatables/extensions/Responsive/css/responsive.bootstrap.min.css">

    <!-- Dark Themes -->
    <!--    <link rel="stylesheet" href="../../static/styles/style-black.min.css">-->
</head>

<body>
<div id="page1">
</div>

<div id="notification-popup" class="notice-popup js__toggle" data-space="75">
    <h2 class="popup-title">Your Notifications</h2>
    <!-- /.popup-title -->
    <div class="content">
        <ul class="notice-list">
            <li>
                <a href="#">
                    <span class="avatar"><img src="../../static/images/avatar-sm-1.jpg" alt=""></span>
                    <span class="name">John Doe</span>
                    <span class="desc">Like your post: “Contact Form 7 Multi-Step”</span>
                    <span class="time">10 min</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="avatar"><img src="../../static/images/avatar-sm-2.jpg" alt=""></span>
                    <span class="name">Anna William</span>
                    <span class="desc">Like your post: “Facebook Messenger”</span>
                    <span class="time">15 min</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="avatar bg-warning"><i class="fa fa-warning"></i></span>
                    <span class="name">Update Status</span>
                    <span class="desc">Failed to get available update data. To ensure the please contact us.</span>
                    <span class="time">30 min</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="avatar"><img src="../../static/images/avatar-1.jpg" alt=""></span>
                    <span class="name">Jennifer</span>
                    <span class="desc">Like your post: “Contact Form 7 Multi-Step”</span>
                    <span class="time">45 min</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="avatar"><img src="../../static/images/avatar-sm-6.jpg" alt=""></span>
                    <span class="name">Michael Zenaty</span>
                    <span class="desc">Like your post: “Contact Form 7 Multi-Step”</span>
                    <span class="time">50 min</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="avatar"><img src="../../static/images/avatar-sm-4.jpg" alt=""></span>
                    <span class="name">Simon</span>
                    <span class="desc">Like your post: “Facebook Messenger”</span>
                    <span class="time">1 hour</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="avatar bg-violet"><i class="fa fa-flag"></i></span>
                    <span class="name">Account Contact Change</span>
                    <span class="desc">A contact detail associated with your account has been changed.</span>
                    <span class="time">2 hours</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="avatar"><img src="../../static/images/avatar-sm-7.jpg" alt=""></span>
                    <span class="name">Helen 987</span>
                    <span class="desc">Like your post: “Facebook Messenger”</span>
                    <span class="time">Yesterday</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="avatar"><img src="../../static/images/avatar-2.jpg" alt=""></span>
                    <span class="name">Denise Jenny</span>
                    <span class="desc">Like your post: “Contact Form 7 Multi-Step”</span>
                    <span class="time">Oct, 28</span>
                </a>
            </li>
            <li>
                <a href="#">
                    <span class="avatar"><img src="../../static/images/avatar-sm-8.jpg" alt=""></span>
                    <span class="name">Thomas William</span>
                    <span class="desc">Like your post: “Facebook Messenger”</span>
                    <span class="time">Oct, 27</span>
                </a>
            </li>
        </ul>
        <a href="#" class="notice-read-more">See more messages <i class="fa fa-angle-down"></i></a>
    </div>
</div>
<div id="message-popup" class="notice-popup js__toggle" data-space="75">
    <h2 class="popup-title">Recent Messages<a href="#" class="pull-right text-danger">New message</a></h2>
    <div class="content">
    </div>
</div>
<div id="wrapper">
    <div class="main-content">
        <div class="row small-spacing">
            <div class="col-xs-12">
                <div class="box-content">
                    <h4 class="box-title">Default</h4>

                    <div style="float: right">
                        <button type="button" class="btn btn-success btn-rounded btn-xs waves-effect waves-light" data-toggle="modal" data-target="#boostrapModal-3">新增优惠券</button>
                    </div>

                    <table id="example" class="table table-striped table-bordered display" style="width:100%">
                        <thead>
                        <tr>
                            <th>编号</th>
                            <th>优惠券金额</th>
                            <th>消费额度</th>
                        </tr>
                        </thead>
                        <tbody id="tbody1">
                        </tbody>
                        <tfoot>
                        <tr>
                            <td colspan="3" align="center">
                                <ul class="pagination" id="byPage">
                                </ul>
                            </td>
                        </tr>
                        </tfoot>
                    </table>
                </div>
            </div>
        </div>
    </div>

</div><!--/#wrapper -->


<div class="modal fade" id="boostrapModal-3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel-2">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel-2">新增优惠券</h4>
            </div>
            <div class="input-group input-group-sm" style="padding-bottom: 5px">
                <span class="input-group-addon">优惠金额</span>
                <input type="text" class="form-control" id="money"  placeholder="请输入优惠券金额"></input>
            </div>
            <div class="input-group input-group-sm"  style="padding-bottom: 5px">
                <span class="input-group-addon">需求</span>
                <input type="text" class="form-control" id="conditionMoney"  placeholder="请设定使用需求"></input>
            </div>
            <div class="modal-footer">
                <button type="button" onclick="document.getElementById('newName').value=''" class="btn btn-xs btn-default btn-sm waves-effect waves-light" data-dismiss="modal">关闭</button>
                <button type="button" onclick="couponSave()" class="btn btn-xs btn-primary btn-sm waves-effect waves-light">确认新增</button>
            </div>
        </div>
    </div>
</div>


<script src="../../static/scripts/jquery.min.js"></script>
<script src="../../static/scripts/modernizr.min.js"></script>
<script src="../../static/plugin/bootstrap/js/bootstrap.min.js"></script>
<script src="../../static/plugin/mCustomScrollbar/jquery.mCustomScrollbar.concat.min.js"></script>
<script src="../../static/plugin/nprogress/nprogress.js"></script>
<script src="../../static/plugin/sweet-alert/sweetalert.min.js"></script>
<script src="../../static/plugin/waves/waves.min.js"></script>

<!-- Data Tables -->
<script src="../../static/plugin/datatables/media/js/jquery.dataTables.min.js"></script>
<script src="../../static/plugin/datatables/media/js/dataTables.bootstrap.min.js"></script>
<script src="../../static/plugin/datatables/extensions/Responsive/js/dataTables.responsive.min.js"></script>
<script src="../../static/plugin/datatables/extensions/Responsive/js/responsive.bootstrap.min.js"></script>
<!--<script src="../../static/scripts/datatables.demo.min.js"></script>-->

<!--<script src="../../static/scripts/main.min.js"></script>-->
<script type="text/javascript">
    $(function () {

        $("#Select").click(function () {
            showByPage(1);
        });

        $(document).ready(function() {
            $("#page1").load("/menu");
        });
        showByPage(1);

    })



    function showByPage(pageNum){
        $.ajax({
            url : "/coupon/findAll",
            type : "post",
            data:{
                "pageNum":pageNum,
            },
            success : function(obj) {
                if (obj.result) {
                    var message = "";
                    $.each(obj.couponList,
                        function(index,coupon) {
                            message += "<tr>";
                            message += "<td>"+(index+1)+"</td>";
                            message += "<td>"+coupon.money+"</td>";
                            message += "<td>"+coupon.conditionMoney+"</td>";
                            message += "</tr>";
                        });
                    $("#tbody1").html(message);

                    var pageMessage = "";
                    pageMessage +='<li class="'+(obj.pageInfo.pageNum==1?"disabled":"")+'"><a onclick="showByPage('+obj.pageInfo.prePage+')">上一页</a></li>';
                    for(var i=1;i<=obj.pageInfo.pages;i++){
                        pageMessage +='<li class="'+(obj.pageInfo.pageNum==i?"active":"")+'"><a onclick="showByPage('+i+')">'+i+' <span class="sr-only">(current)</span></a></li>';
                    }
                    pageMessage +='<li class="'+(obj.pageInfo.pageNum==obj.pageInfo.pages?"disabled":"")+'"><a onclick="showByPage('+obj.pageInfo.nextPage+')">下一页</a></li>';
                    $("#byPage").html(pageMessage);
                }

            }

        });
    }



    //新增账户
    function couponSave() {
        $.ajax({
            url: "/coupon/couponSave",
            type: "post",
            data: {
                "money": $("#money").val(),
                "conditionMoney":$("#conditionMoney").val(),
            },
            success: function (data) {
                window.location.href = "/coupon/couponlist";
            }
        });

    }


</script>
</body>
</html>